package com.kay.service;

import com.kay.api.IUserService;
import com.kay.pojo.User;
import com.kay.anno.RPCServer;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

/**
 * @Description:
 * @Author: Kay
 * @CreateDate: 2021/8/27$ 18:49$
 * @UpdateUser: Kay
 * @UpdateDate: 2021/8/27$ 18:49$
 */
@Service
@RPCServer
public class UserServiceImpl implements IUserService {
    Map<Object, User> userMap = new HashMap();
    @Override
    public User findById(int id) {
        if (userMap.size() == 0) {
            User user1 = new User();
            user1.setId(1);
            user1.setName("张三");
            User user2 = new User();
            user2.setId(2);
            user2.setName("李四");
            userMap.put(user1.getId(), user1);
            userMap.put(user2.getId(), user2);
        }
        return userMap.get(id);
    }
}
